package com.zmm.zebulon.starter.api.log.core.service;

import cn.hutool.core.bean.BeanUtil;
import com.zmm.zebulon.module.infra.api.api.ApiErrorLogApi;
import com.zmm.zebulon.module.infra.api.api.dto.ApiErrorLogCreateReqDTO;
import com.zmm.zebulon.starter.api.log.core.domain.ApiErrorLog;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.Async;

/**
 * description: API 错误日志 Framework Service 实现类<br>
 * 基于 {@link ApiErrorLogApi} 服务，记录错误日志
 *
 * @author zebulon
 * package com.zmm.zebulon.starter.web.api.log.core.service
 * name: ApiErrorLogFrameworkServiceImpl
 * date 2024/1/12 22:47
 */
@RequiredArgsConstructor
public class ApiErrorLogFrameworkServiceImpl implements ApiErrorLogFrameworkService {

    private final ApiErrorLogApi apiErrorLogApi;

    @Override
    @Async
    public void createApiErrorLog(ApiErrorLog apiErrorLog) {
        ApiErrorLogCreateReqDTO reqDTO = BeanUtil.copyProperties(apiErrorLog, ApiErrorLogCreateReqDTO.class);
        apiErrorLogApi.createApiErrorLog(reqDTO);
    }

}
